﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;
using System.Collections.Specialized;

namespace Billing
{
    public class SettingManager
    {
        private static NameValueCollection sec;

        public static string getSetting(string key)
        {
            return getSetting(key, true);
        }

        public static string getSetting(string key, bool enforceSecurity)
        {
            if (sec == null)
            {
                sec = ConfigurationManager.AppSettings;
            }

            string value = sec.Get(key);
            if (string.IsNullOrEmpty(value)) return value;


            if (enforceSecurity && Profile.AppSettingsSecurityEnabled)
            {
                return CryptoUtils.RSADecrypt(value);
            }

            return value;
        }
    }
}
